Fix CRC From 3 Png
My Friend send me some images, but something wrong, plzz help me repair this image, for get this flag *note: bukan file corrupt author salah format flag:( format flag untuk chall ini : hackfest0x05 author: @wisnuazfarm discord: zzzzzzzzzzzzz#9742
ls
qr.png
qrr.png
qrrr.png
pngcheck *
zlib warning: different version (expected 1.2.11, using 1.3.1)
qr.png CRC error in chunk IHDR (computed 421d2d39, expected b2b7b9bd)
ERROR: qr.png
qrr.png CRC error in chunk IHDR (computed ec2a9aa0, expected 4f32eac7)
ERROR: qrr.png
qrrr.png CRC error in chunk IHDR (computed be792774, expected 95b8e875)
ERROR: qrrr.png
Errors were detected in 3 of the 3 files tested.
Get script for brute crc to get correct width and height.
to get crc :
match the struct with : https://i.stack.imgur.com/hcIIO.png
after we got the crc, we calculate the correct width and height using this script :
from binascii import crc32
# B2 B7 B9 BD crc for qr.png
# 4F 32 EA C7 crc for qrr.png
# 95 B8 E8 75 crc for qrrr.png
crc_checksum = int.from_bytes(b'\x95\xb8\xe8\x75',byteorder='big')
for h in range(0xffff):
for w in range(0xffff):
#IHDR Chunk + (4 Bytes Width) + (4 Bytes Height) + Bit Depth + Col Type + Compression Method + Filter Method + Interlace Method
#set byte structure bit depth 2byte setelah size
crc=b"\x49\x48\x44\x52"+w.to_bytes(4,byteorder='big')+h.to_bytes(4,byteorder='big')+b"\x08\x02\x00\x00\x00"
if crc32(crc) % (1<<32) == crc_checksum:
print('Image Width: ',end="")
print(hex(w))
print('Image Height :',end="")
print(hex(h))
after we got the correct image width and height, we edit in in bless . example of qr.png :
python3 solver.py
Image Width: 0xc7
Image Height :0x2d
we edit in bless before it was
00 00 AA AA 00 00 AA AA
we edit it to
00 00 00 C7 00 00 00 2D
. and then we check pngcheck. and its correct.
( do same for qr, qrr, qrr )
and combine 3 of this images and we get the flag.